﻿// PleaseRestWindow.cpp
// cpp file of PleaseRestWindow.h

#include "PleaseRestWindow.h"

PleaseRestWindow::PleaseRestWindow()
{
	
	
	
	//label to show message
    notifyLabel = new QLabel(tr("为防止你在电脑前坐太长时间，本程序会在一定的时间间隔后提醒你，请在系统提示弹出后休息一下，防止疲劳！\n身体是革命的本钱！"));
    notifyLabel->setWordWrap(true);
    notifyLabel->setFrameStyle(QFrame::Raised | QFrame::Panel);
    notifyLabel->setLineWidth(2);
    
    
    // a spin box to scale time
    timeLabel = new QLabel(tr("提醒时间："));
    timeLabel->setAlignment(Qt::AlignRight);
    timeSpinBox = new QSpinBox();
    timeSpinBox->setRange(30, 60);
    timeSpinBox->setValue(45);
    timeSpinBox->setSingleStep(1);
    //time set layout
    timeSetLayout = new QHBoxLayout();
    timeSetLayout->addWidget(timeLabel);
    timeSetLayout->addWidget(timeSpinBox);
    
    
    //control section, containing ok button and quit button
    // ok button
    okButton = new QPushButton(tr("我知道了。"));
    // quit button, red backbround
    quitButton = new QPushButton(tr("退出"));
    quitButtonPalette = quitButton->palette();
    quitButtonPalette.setColor(QPalette::Button, Qt::red);
    quitButton->setPalette(quitButtonPalette);    
    
    setLayout = new QHBoxLayout;
    setLayout->addWidget(okButton);
    setLayout->addWidget(quitButton);
    
    
    //widget layout
    vBoxLayout = new QVBoxLayout(this);
    vBoxLayout->addWidget(notifyLabel);
    vBoxLayout->addLayout(timeSetLayout);
    vBoxLayout->addLayout(setLayout);
    
    
    
    this->resize(300, 200);
    //this->setLayout(this->vBoxLayout);
    
	
	// set interval
	this->interval = timeSpinBox->value();

    // set okButton slot
    QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
	
}

PleaseRestWindow::~PleaseRestWindow(){
	
}

int PleaseRestWindow::getInterval(){
    return this->interval;
}
